import java.util.Scanner;

/**
 * @author vivi
 * @description
 * @date 2024/5/18
 */
public class demo2 {
    public static void main (String[] args) {
        // 滑动窗口
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(); // 数组中元素个数
        int k = scanner.nextInt(); // 差值 <=
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

        int right = 0, left = 0, ret = 0;
        while (right < n) {
            if (arr[right] - arr[left] < k) {
                left++;
            }
            ret = Math.max(ret, right - left + 1);
            right++;
        }
        System.out.println(ret);
    }
    public static void main1 (String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(); // 数组中元素个数
        int k = scanner.nextInt(); // 差值 <=
        int[] arr = new int[n];
        int count = 0;

        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (Math.abs(arr[j] - arr[i]) < k) {
                    count++;

                }
                break;
            }
        }
        System.out.println(count);
    }
}
